/*
 * @Author: sean_kei@163.com
 * @Date: 2021-06-08 15:07:28
 * @LastEditors: sean_kei@163.com
 * @LastEditTime: 2022-08-03 11:07:02
 */
package com.wxhandle.cleandemo.application.dto.identity;

import java.util.ArrayList;
import java.util.List;

import com.wxhandle.cleandemo.core.domain.identity.SysService.ClaimType;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class SysServiceDto {

    private String id;

    private String description;

    private ClaimType type;

    private List<SysClaimDto> claims;

    public void setVueMenus(List<VueMenuDto> vueMenus) {
        setType(ClaimType.MENU);
        this.claims = new ArrayList<>();
        vueMenus.forEach((vm) -> {
            int i=0;
            this.claims.add(SysClaimDto.of(vm, i++));
        });
    }

    public static SysServiceDto of(String service, String desc, List<VueMenuDto> menus) {
        SysServiceDto serviceDto = new SysServiceDto();
        serviceDto.setId(service);
        serviceDto.setDescription(desc);
        serviceDto.setVueMenus(menus);
        return serviceDto;
    }
}
